<!-- Dom模板 -->
<template>
  <div class="ok" @click="goBack" ref="ok">
    <!-- Dom内容 -->
    <div class="container">
      <!-- 加载loadding时才能旋转，方便后续控制 -->

      <div class="loader loadding" ref="loader"></div>
      <h3 class="cg">{{ changeRes }}</h3>
    </div>
  </div>
</template>

<script>
// import a from './a'; // 引入组件
export default {
  name: "",
  props:['type'],
  data() {
    return {
      msg: "测试",
      info: false,
    };
  },
  // 生命周期 - 创建完成（访问当前this实例）
  computed: {
    changeRes() {
      if (this.$store.state.my.changState) {
        this.$nextTick(()=>{
          this.$refs["loader"].classList.remove("loadding");
        //     // 增加check样式让对号显示
        this.$refs["loader"].classList.add("check");
        })
        
        return this.$store.state.my.codeState
      }else{
        return this.$props.type
      }
    },
  },
  created() {},
  // 生命周期 - 挂载完成（访问DOM元素）12345678q
  mounted() {
    let timer = setTimeout(() => {
            this.$refs["ok"].style.opacity = "1";
          }, 200);
  },
  // Vue方法定义
  methods: {
    goBack(){
      this.$emit('close',false)
    }
  },
};
</script>

<style scoped>
/* @import url(''); 引入css类 */

.ok {
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: "Montserrat", sans-serif, Arial, "Microsoft Yahei";
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  opacity: 0;
  transition: all .3s linear;
}
.container {
  width: 8rem;
  height: 4rem;
  background: white;
  border-radius: 15px;
  margin: 0 auto;
}
.cg {
  /* position: absolute; */
  min-width: 2rem;
  max-width: 2.3rem;
  margin: 0 auto;
  /* top: 53.8%; */
  text-align: center;
  color: #f33a65;
}
.loader {
  position: relative;
  width: 1.866667rem;
  height: 1.866667rem;
  /* background-color: lawngreen; */
  border-radius: 50%;
  border: 5px solid #f33a65;
  transition: 0.5s;
  margin: 0.533333rem auto;
}

.loader.loadding {
  animation: animate_rotate 1s linear infinite both;
  border-color: white;
  border-left-color: #f33a65;
}

/* 变色+旋转 */

@keyframes animate_rotate {
  0% {
    transform: rotate(0deg);
    border-left-color: #f33a65;
  }
  25% {
    border-left-color: #f33a65;
  }
  50% {
    border-left-color: #f33a65;
  }
  75% {
    border-left-color: #f33a65;
  }
  100% {
    transform: rotate(-360deg);
    border-left-color: #f33a65;
  }
}

/* 开始做对号 */

.loader::before {
  position: absolute;
  content: "";
  top: 50%;
  left: 0.25rem;
  /* left: 50%; */
  border: 5px solid #f33a65;
  border-left-width: 0;
  border-bottom-width: 0;
  /* background-color: #7591AD; */
  /* 关键点，这个地方琢磨了好久都没搞明白。 */
  transform: scaleX(-1) rotate(135deg);
  transform-origin: left top;
  display: none;
}

.loader.check::before {
  display: block;
  animation: animate_check 1s linear 1 both;
}

@keyframes animate_check {
  0% {
    width: 0px;
    height: 0px;
  }
  43% {
    width: 0.533333rem;
    height: 0px;
  }
  100% {
    width: 0.533333rem;
    height: 1.066667rem;
  }
}
</style>